<?php
class User_Form_LoginForm extends Zend_Form
{
   public function init()
    {
       $this->setAction ( '' )
          ->setMethod ( 'post' );
      
      // Create and configure username element:
      $username = $this->createElement ( 'text', 'username' );
      $username->addValidator ( 'alnum' )
      		->setLabel('Username:')
            ->addValidator ( 'regex', false, array ('/^[a-z]+/' ) )
            ->addValidator ( 'stringLength', false, array (6, 20 ) )
            ->setRequired ( true )
            ->addFilter ( 'StringToLower' )
            ->setAttrib('class', 'input-text-login');
      
      // Create and configure password element:
      $password = $this->createElement ( 'password', 'password' );
      $password->addValidator ( 'StringLength', false, array (6 , 20) )
             ->setRequired ( true )
             ->setLabel('Password:')
            ->setAttrib('class', 'input-text-login');
      
      $submit = $this->createElement('submit','login',array ('label' => 'Login' ));
      $submit->setAttrib('class', 'button');   
      // Add elements to form:
      $this->addElement ( $username )
           ->addElement ( $password )           
           ->addElement($submit);
    }
}